<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>登录弹出层</title>
	<link rel="stylesheet" href="css/css.css">
</head>
<body>
	<p style="text-align:center;margin-top:30px;"><button class="btn">发布</button></p>
	<!-- form_wish -->
	<div id="send_form" style="display:none;">
		<p class="title"><a id="close"></a></p>
		<form id="send" name="wish">
			<p class="nichen">标题:</p>
			<input type="input" name="username" class="nich_input"/>
			<p class="wish">摘要:</p>
			<textarea name="content" id="content"></textarea>
			<input type="submit" value="立即发布" class="send-btn"/>
		</form>
	</div>
	<!-- form_wish -->
	<script type="text/javascript" src="js/jquery2.1.4.min.js"></script>
	<script type="text/javascript" src="js/Drag.js"></script>
	<script type="text/javascript">
		//页面加载完成
		window.onload = function(){
			//点击发布让弹出层显示
			document.querySelector('.btn').onclick=function(){
				document.getElementById('send_form').style.display='block';
			}
			new Drag('send_form');
			/**
			 * 获取事件源对象相关-提交表单
			 */
			var sendBtn = document.querySelector('.send-btn');
			var title = document.querySelector('.nich_input');
			var descr = document.querySelector('#content');
			sendBtn.onclick=function(e){
				var oTit = title.value;
				var odesc = descr.value;
				
				//数据校验
				if(oTit==''||oTit.length==0||oTit==undefined||oTit==null){
					alert('请输入标题');
					return;
				}
				if(odesc==''||odesc.length==0||odesc==undefined||odesc==null){
					alert('请输入摘要');
					return;
				}
				//ajax
				$.ajax({
					url:'https://cache.iminutes.cn/api/soft/test.html',
					type:'POST',
					data:{
						title:oTit,
						descr:odesc
					},
					dataType:'json',
					success:function(res){
						console.log(res);
						if(res.status==400){
							alert('请求错误');
						}else{
							...
						}
					}
				});
				//alert(oTit+'='+odesc);
				//去掉form的默认跳转action
				e.preventDefault();
			}
			
			
		}
		
		
		
	</script>
</body>
</html>